<template>
  <view>
    <view class="address-box">
      <view class="address-top">
        <button @click="confirm">取消</button>
        <button @click="confirm">确认</button>
      </view>
      <view class="address-item" :class="{active: item.mo}" v-for="(item,index) in address" :key="index" @click="addItem(index)">
        <view class="address-item-top">
          <text>姓名:{{item.name}}</text>
          <text>电话:{{item.phone}}</text>
        </view>
        <view class="adress-item-bom">
          <text>地址: {{item.dz}}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import { useUserStore } from '../../store/user'
  const userStore = useUserStore()
  export default {
    data() {
      return {
        address: []
      }
    },
    methods: {
      addItem(index) {
        this.address[index].mo = !this.address[index].mo
      },
      confirm() {
        uni.navigateBack()
      }
    },
    onLoad() {
      console.log(userStore);
      this.address = userStore.address
    }
  }
</script>

<style lang="scss">
.address-box {
  height: 100%;
  padding: 5px;
  button{
    border: none;
    background-color: #fff;
    margin: 0;
  }
  .address-top {
    display: flex;
    justify-content: space-between;
  }
  .address-item {
    border: 1px solid #efefef;
    padding: 10px 0;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 60px;
    .address-item-top {
      display: flex;
      justify-content: space-between;
    }
    &.active {
      background-color: #efefef;
    }
  }
}
</style>
